Open
Conversation
This allows using the same code for both "specially named" and regular methods. This uses :__delegate as the name, which may be visible to users in backtraces for these methods. Co-authored-by: Luke Gruber <[email protected]>
73f7795 to
82125cd
Compare
byroot
approved these changes
Dec 18, 2025
| source << "def #{method}(...); __getobj__.__send__(#{method.inspect}, ...); end" | ||
| methods_to_define.each do |target_name, is_protected| | ||
| unless target_name.match?(/\A[a-zA-Z]\w*[!\?]?\z/) | ||
| placeholder_name = :__delegate |
Member
There was a problem hiding this comment.
Suggested change
| placeholder_name = :__delegate | |
| placeholder_name = "__delegate_#{target_name.unpack1("h*")}" |
Active Model unpack the string in hexadecimal to get a unique name. May or may not be a good idea. Make sure there is no conflict and get unique name, but also define more symbols?
Up to you.
Member
Author
There was a problem hiding this comment.
I wanted to avoid creating extra symbols and since we're removing them I don't think there's a need for them to be unique.
It might be worth handling the case that we're delegating to something which has exactly __delegate defined...
Co-authored-by: Jean Boussier <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As @byroot suggested in #53 (comment)
This allows using the same code for both "specially named" and regular methods. This uses :__delegate as the placeholder method name, which may be visible to users in backtraces for these methods.